<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Range tree</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Range_tree"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.math.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Range_tree rootpage-Range_tree skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Range tree</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<style data-mw-deduplicate="TemplateStyles:r1295905060">
/* start https://en.wikipedia.org/ */
.mw-parser-output .infobox-subbox{padding:0;border:none;margin:-3px;width:auto;min-width:100%;font-size:100%;clear:none;float:none;background-color:transparent}.mw-parser-output .infobox-3cols-child{margin:auto}.mw-parser-output .infobox .navbar{font-size:100%}@media screen{html.skin-theme-clientpref-night .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media(min-width:640px){body.skin--responsive .mw-parser-output .infobox-table{display:table!important}body.skin--responsive .mw-parser-output .infobox-table>caption{display:table-caption!important}body.skin--responsive .mw-parser-output .infobox-table>tbody{display:table-row-group}body.skin--responsive .mw-parser-output .infobox-table th,body.skin--responsive .mw-parser-output .infobox-table td{padding-left:inherit;padding-right:inherit}}
/* end https://en.wikipedia.org/ */
</style><table class="infobox"><tbody><tr><th colspan="2" class="infobox-above">Range tree</th></tr><tr><th scope="row" class="infobox-label"><a href="List_of_data_structures" title="List of data structures">Type</a></th><td class="infobox-data">tree</td></tr><tr><th scope="row" class="infobox-label">Invented</th><td class="infobox-data">1979</td></tr><tr><th scope="row" class="infobox-label">Invented by</th><td class="infobox-data"><a href="Jon_Louis_Bentley" class="mw-redirect" title="Jon Louis Bentley">Jon Louis Bentley</a></td></tr><tr><td colspan="2" class="infobox-full-data"><table class="infobox-subbox infobox-3cols-child infobox-table"><tbody><tr><th colspan="4" class="infobox-header"><a href="Time_complexity" title="Time complexity">Time complexity</a> in <a href="Big_O_notation" title="Big O notation">big O notation</a></th></tr><tr><th scope="row" class="infobox-label" style="white-space:nowrap;">Operation</th><td class="infobox-data infobox-data-a">
<b>Average</b></td><td class="infobox-data infobox-data-b">
<b>Worst case</b></td></tr><tr><th scope="row" class="infobox-label" style="white-space:nowrap;">Search</th><td class="infobox-data infobox-data-a">
<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log ^{d}n+k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo>+</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log ^{d}n+k)}</annotation>
</semantics>
</math></span><img src="./9312fe5a8de4d58497ddcac118796736c2d06629.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.48ex; height:3.176ex;" alt="{\displaystyle O(\log ^{d}n+k)}" loading="lazy"></span></td><td class="infobox-data infobox-data-b">
<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log ^{d}n+k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo>+</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log ^{d}n+k)}</annotation>
</semantics>
</math></span><img src="./9312fe5a8de4d58497ddcac118796736c2d06629.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.48ex; height:3.176ex;" alt="{\displaystyle O(\log ^{d}n+k)}" loading="lazy"></span></td></tr><tr><th colspan="4" class="infobox-header"><a href="Space_complexity" title="Space complexity">Space complexity</a></th></tr><tr><th scope="row" class="infobox-label" style="white-space:nowrap;">Space</th><td class="infobox-data infobox-data-a">
<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log ^{d-1}n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log ^{d-1}n)}</annotation>
</semantics>
</math></span><img src="./4a35f590b482e5c2772ac500016102d1d829200e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.311ex; height:3.176ex;" alt="{\displaystyle O(n\log ^{d-1}n)}" loading="lazy"></span></td><td class="infobox-data infobox-data-b">
<span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log ^{d-1}n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log ^{d-1}n)}</annotation>
</semantics>
</math></span><img src="./4a35f590b482e5c2772ac500016102d1d829200e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.311ex; height:3.176ex;" alt="{\displaystyle O(n\log ^{d-1}n)}" loading="lazy"></span></td></tr></tbody></table></td></tr></tbody></table>
<p>In <a href="Computer_science" title="Computer science">computer science</a>, a <b>range tree</b> is an <a href="Ordered_tree_data_structure" class="mw-redirect" title="Ordered tree data structure">ordered tree</a> <a href="Data_structure" title="Data structure">data structure</a> to hold a list of points. It allows all points within a given range to be <a href="Range_query_(computer_science)" title="Range query (computer science)">reported</a> efficiently, and is typically used in two or higher dimensions. Range trees were introduced by <a href="Jon_Louis_Bentley" class="mw-redirect" title="Jon Louis Bentley">Jon Louis Bentley</a> in 1979.<sup id="cite_ref-Bentley79_1-0" class="reference"><a href="#cite_note-Bentley79-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup> Similar data structures were discovered independently by Lueker,<sup id="cite_ref-Lueker78_2-0" class="reference"><a href="#cite_note-Lueker78-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup> Lee and Wong,<sup id="cite_ref-LeeWong80_3-0" class="reference"><a href="#cite_note-LeeWong80-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> and Willard.<sup id="cite_ref-Willard79_4-0" class="reference"><a href="#cite_note-Willard79-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
The range tree is an alternative to the <a href="K-d_tree" title="K-d tree"><i>k</i>-d tree</a>. Compared to <i>k</i>-d trees, range trees offer faster query times of (in <a href="Big_O_notation" title="Big O notation">Big O notation</a>) <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log ^{d}n+k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo>+</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log ^{d}n+k)}</annotation>
</semantics>
</math></span><img src="./9312fe5a8de4d58497ddcac118796736c2d06629.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.48ex; height:3.176ex;" alt="{\displaystyle O(\log ^{d}n+k)}" loading="lazy"></span> but worse storage of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log ^{d-1}n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log ^{d-1}n)}</annotation>
</semantics>
</math></span><img src="./4a35f590b482e5c2772ac500016102d1d829200e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.311ex; height:3.176ex;" alt="{\displaystyle O(n\log ^{d-1}n)}" loading="lazy"></span>, where <i>n</i> is the number of points stored in the tree, <i>d</i> is the dimension of each point and <i>k</i> is the number of points reported by a given query.
</p><p>In 1990, <a href="Bernard_Chazelle" title="Bernard Chazelle">Bernard Chazelle</a> improved this to query time <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log ^{d-1}n+k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo>+</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log ^{d-1}n+k)}</annotation>
</semantics>
</math></span><img src="./d8ec3b35521f0bff4c75d53f8181797721d7f513.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:15.58ex; height:3.176ex;" alt="{\displaystyle O(\log ^{d-1}n+k)}" loading="lazy"></span> and space complexity <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O\left(n\left({\frac {\log n}{\log \log n}}\right)^{d-1}\right)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mrow>
<mo>(</mo>
<mrow>
<mi>n</mi>
<msup>
<mrow>
<mo>(</mo>
<mrow class="MJX-TeXAtom-ORD">
<mfrac>
<mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
</mrow>
<mrow>
<mi>log</mi>
<mo><!-- --></mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
</mrow>
</mfrac>
</mrow>
<mo>)</mo>
</mrow>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
</mrow>
<mo>)</mo>
</mrow>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O\left(n\left({\frac {\log n}{\log \log n}}\right)^{d-1}\right)}</annotation>
</semantics>
</math></span><img src="./85b11376867cb32e5050caecac9ad8985a2e3418.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -3.171ex; width:22.799ex; height:7.509ex;" alt="{\displaystyle O\left(n\left({\frac {\log n}{\log \log n}}\right)^{d-1}\right)}" loading="lazy"></span>.<sup id="cite_ref-Chazelle90_1_5-0" class="reference"><a href="#cite_note-Chazelle90_1-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Chazelle90_2_6-0" class="reference"><a href="#cite_note-Chazelle90_2-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="Data_structure">Data structure</h2></div>
<p>A range tree on a set of 1-dimensional points is a balanced <a href="Binary_search_tree" title="Binary search tree">binary search tree</a> on those points. The points stored in the tree are stored in the leaves of the tree; each internal node stores the largest value of its left subtree.
A range tree on a set of points in <i>d</i>-dimensions is a <a href="Recursive_data_type" title="Recursive data type">recursively defined</a> multi-level <a href="Binary_search_tree" title="Binary search tree">binary search tree</a>. Each level of the data structure is a binary search tree on one of the <i>d</i>-dimensions.
The first level is a binary search tree on the first of the <i>d</i>-coordinates. Each vertex <i>v</i> of this tree contains an associated structure that is a (<i>d</i>−1)-dimensional range tree on the last (<i>d</i>−1)-coordinates of the points stored in the subtree of <i>v</i>.
</p>
<div class="mw-heading mw-heading2"><h2 id="Operations">Operations</h2></div>
<div class="mw-heading mw-heading3"><h3 id="Construction">Construction</h3></div>
<p>A 1-dimensional range tree on a set of <i>n</i> points is a binary search tree, which can be constructed in <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log n)}</annotation>
</semantics>
</math></span><img src="./9d2320768fb54880ca4356e61f60eb02a3f9d9f1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.118ex; height:2.843ex;" alt="{\displaystyle O(n\log n)}" loading="lazy"></span> time. Range trees in higher dimensions are constructed recursively by constructing a balanced binary search tree on the first coordinate of the points, and then, for each vertex <i>v</i> in this tree, constructing a (<i>d</i>−1)-dimensional range tree on the points contained in the subtree of <i>v</i>. Constructing a range tree this way would require <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log ^{d}n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log ^{d}n)}</annotation>
</semantics>
</math></span><img src="./9c081c8af02814b7a0807c486f03ead35d9aebcc.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:11.21ex; height:3.176ex;" alt="{\displaystyle O(n\log ^{d}n)}" loading="lazy"></span> time.
</p><p>This construction time can be improved for 2-dimensional range trees to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log n)}</annotation>
</semantics>
</math></span><img src="./9d2320768fb54880ca4356e61f60eb02a3f9d9f1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.118ex; height:2.843ex;" alt="{\displaystyle O(n\log n)}" loading="lazy"></span>.<sup id="cite_ref-DutchBook3E_7-0" class="reference"><a href="#cite_note-DutchBook3E-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>
Let <i>S</i> be a set of <i>n</i> 2-dimensional points. If <i>S</i> contains only one point, return a leaf containing that point. Otherwise, construct the associated structure of <i>S</i>, a 1-dimensional range tree on the <i>y</i>-coordinates of the points in <i>S</i>. Let <i>x</i><sub>m</sub> be the median <i>x</i>-coordinate of the points. Let <i>S</i><sub>L</sub> be the set of points with <i>x</i>-coordinate less than or equal to <i>x</i><sub>m</sub> and let <i>S</i><sub>R</sub> be the set of points with <i>x</i>-coordinate greater than <i>x</i><sub>m</sub>. Recursively construct <i>v</i><sub>L</sub>, a 2-dimensional range tree on <i>S</i><sub>L</sub>, and <i>v</i><sub>R</sub>, a 2-dimensional range tree on <i>S</i><sub>R</sub>. Create a vertex <i>v</i> with left-child <i>v</i><sub>L</sub> and right-child <i>v</i><sub>R</sub>.
If we sort the points by their <i>y</i>-coordinates at the start of the algorithm, and maintain this ordering when splitting the points by their <i>x</i>-coordinate, we can construct the associated structures of each subtree in linear time.
This reduces the time to construct a 2-dimensional range tree to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log n)}</annotation>
</semantics>
</math></span><img src="./9d2320768fb54880ca4356e61f60eb02a3f9d9f1.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:10.118ex; height:2.843ex;" alt="{\displaystyle O(n\log n)}" loading="lazy"></span>, and also reduces the time to construct a <i>d</i>-dimensional range tree to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(n\log ^{d-1}n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>n</mi>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(n\log ^{d-1}n)}</annotation>
</semantics>
</math></span><img src="./4a35f590b482e5c2772ac500016102d1d829200e.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.311ex; height:3.176ex;" alt="{\displaystyle O(n\log ^{d-1}n)}" loading="lazy"></span>.
</p>
<div class="mw-heading mw-heading3"><h3 id="Range_queries">Range queries</h3></div>
<p>A <a href="Range_query_(data_structures)" class="mw-redirect" title="Range query (data structures)">range query</a> on a range tree reports the set of points that lie inside a given interval. To report the points that lie in the interval [<i>x</i><sub>1</sub>, <i>x</i><sub>2</sub>], we start by searching for <i>x</i><sub>1</sub> and <i>x</i><sub>2</sub>. At some vertex in the tree, the search paths to <i>x</i><sub>1</sub> and <i>x</i><sub>2</sub> will diverge. Let <i>v</i><sub>split</sub> be the last vertex that these two search paths have in common. For every vertex <i>v</i> in the search path from <i>v</i><sub>split</sub> to <i>x</i><sub>1</sub>, if the value stored at <i>v</i> is greater than <i>x</i><sub>1</sub>, report every point in the right-subtree of <i>v</i>. If <i>v</i> is a leaf, report the value stored at <i>v</i> if it is inside the query interval. Similarly, reporting all of the points stored in the left-subtrees of the vertices with values less than <i>x</i><sub>2</sub> along the search path from <i>v</i><sub>split</sub> to <i>x</i><sub>2</sub>, and report the leaf of this path if it lies within the query interval.
</p><p>Since the range tree is a balanced binary tree, the search paths to <i>x</i><sub>1</sub> and <i>x</i><sub>2</sub> have length <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log n)}</annotation>
</semantics>
</math></span><img src="./aae0f22048ba6b7c05dbae17b056bfa16e21807d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:8.336ex; height:2.843ex;" alt="{\displaystyle O(\log n)}" loading="lazy"></span>. Reporting all of the points stored in the subtree of a vertex can be done in linear time using any <a href="Tree_traversal" title="Tree traversal">tree traversal</a> algorithm. It follows that the time to perform a range query is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log n+k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo>+</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log n+k)}</annotation>
</semantics>
</math></span><img src="./1a7c999f07c8c2b6ba6e06e8532628f7e1c097b6.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:12.388ex; height:2.843ex;" alt="{\displaystyle O(\log n+k)}" loading="lazy"></span>, where <i>k</i> is the number of points in the query interval.
</p><p>Range queries in <i>d</i>-dimensions are similar. Instead of reporting all of the points stored in the subtrees of the search paths, perform a (<i>d</i>−1)-dimensional range query on the associated structure of each subtree. Eventually, a 1-dimensional range query will be performed and the correct points will be reported. Since a <i>d</i>-dimensional query consists of <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log n)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<mi>log</mi>
<mo><!-- --></mo>
<mi>n</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log n)}</annotation>
</semantics>
</math></span><img src="./aae0f22048ba6b7c05dbae17b056bfa16e21807d.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:8.336ex; height:2.843ex;" alt="{\displaystyle O(\log n)}" loading="lazy"></span> (<i>d</i>−1)-dimensional range queries, it follows that the time required to perform a <i>d</i>-dimensional range query is <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log ^{d}n+k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo>+</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log ^{d}n+k)}</annotation>
</semantics>
</math></span><img src="./9312fe5a8de4d58497ddcac118796736c2d06629.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:13.48ex; height:3.176ex;" alt="{\displaystyle O(\log ^{d}n+k)}" loading="lazy"></span>, where <i>k</i> is the number of points in the query interval. This can be reduced to <span class="mwe-math-element mwe-math-element-inline"><span class="mwe-math-mathml-inline mwe-math-mathml-a11y" style="display: none;"><math xmlns="http://www.w3.org/1998/Math/MathML" alttext="{\displaystyle O(\log ^{d-1}n+k)}">
<semantics>
<mrow class="MJX-TeXAtom-ORD">
<mstyle displaystyle="true" scriptlevel="0">
<mi>O</mi>
<mo stretchy="false">(</mo>
<msup>
<mi>log</mi>
<mrow class="MJX-TeXAtom-ORD">
<mi>d</mi>
<mo>−<!-- − --></mo>
<mn>1</mn>
</mrow>
</msup>
<mo><!-- --></mo>
<mi>n</mi>
<mo>+</mo>
<mi>k</mi>
<mo stretchy="false">)</mo>
</mstyle>
</mrow>
<annotation encoding="application/x-tex">{\displaystyle O(\log ^{d-1}n+k)}</annotation>
</semantics>
</math></span><img src="./d8ec3b35521f0bff4c75d53f8181797721d7f513.svg" class="mwe-math-fallback-image-inline mw-invert skin-invert" aria-hidden="true" style="vertical-align: -0.838ex; width:15.58ex; height:3.176ex;" alt="{\displaystyle O(\log ^{d-1}n+k)}" loading="lazy"></span> using a variant of <a href="Fractional_cascading" title="Fractional cascading">fractional cascading</a>.<sup id="cite_ref-Lueker78_2-1" class="reference"><a href="#cite_note-Lueker78-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-Willard79_4-1" class="reference"><a href="#cite_note-Willard79-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-DutchBook3E_7-1" class="reference"><a href="#cite_note-DutchBook3E-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="K-d_tree" title="K-d tree"><i>k</i>-d tree</a></li>
<li><a href="Segment_tree" title="Segment tree">Segment tree</a></li>
<li><a href="Range_searching" title="Range searching">Range searching</a></li></ul>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */
.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}
/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-Bentley79-1"><span class="mw-cite-backlink"><b><a href="#cite_ref-Bentley79_1-0">^</a></b></span> <span class="reference-text"><style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */
.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}
/* end https://en.wikipedia.org/ */
</style><cite id="CITEREFBentley1979" class="citation journal cs1">Bentley, J. L. (1979). <a rel="nofollow" class="external text" href="https://apps.dtic.mil/sti/pdfs/ADA061627.pdf">"Decomposable searching problems"</a> <span class="cs1-format">(PDF)</span>. <i>Information Processing Letters</i>. <b>8</b> (5): <span class="nowrap">244–</span>251. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1016%2F0020-0190%2879%2990117-0">10.1016/0020-0190(79)90117-0</a>. <a rel="nofollow" class="external text" href="https://web.archive.org/web/20170924023643/http://www.dtic.mil/get-tr-doc/pdf?AD=ADA061627">Archived</a> from the original on September 24, 2017.</cite></span>
</li>
<li id="cite_note-Lueker78-2"><span class="mw-cite-backlink">^ <a href="#cite_ref-Lueker78_2-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Lueker78_2-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFLueker1978" class="citation book cs1">Lueker, G. S. (1978). "A data structure for orthogonal range queries". <i>19th Annual Symposium on Foundations of Computer Science (sfcs 1978)</i>. pp. <span class="nowrap">28–</span>21. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1109%2FSFCS.1978.1">10.1109/SFCS.1978.1</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:14970942">14970942</a>.</cite></span>
</li>
<li id="cite_note-LeeWong80-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-LeeWong80_3-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFLeeWong1980" class="citation journal cs1">Lee, D. T.; Wong, C. K. (1980). "Quintary trees: A file structure for multidimensional database systems". <i>ACM Transactions on Database Systems</i>. <b>5</b> (3): 339. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F320613.320618">10.1145/320613.320618</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:2547376">2547376</a>.</cite></span>
</li>
<li id="cite_note-Willard79-4"><span class="mw-cite-backlink">^ <a href="#cite_ref-Willard79_4-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-Willard79_4-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFWillard" class="citation techreport cs1">Willard, Dan E. <i>The super-</i>b<i>-tree algorithm</i> (Technical report). Cambridge, MA: Aiken Computer Lab, Harvard University. TR-03-79.</cite></span>
</li>
<li id="cite_note-Chazelle90_1-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-Chazelle90_1_5-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFChazelle1990" class="citation journal cs1">Chazelle, Bernard (1990). <a rel="nofollow" class="external text" href="http://www.cs.princeton.edu/~chazelle/pubs/LBOrthoRangeSearchReporting.pdf">"Lower Bounds for Orthogonal Range Searching: I. The Reporting Case"</a> <span class="cs1-format">(PDF)</span>. <i>Journal of the ACM</i>. <b>37</b> (2): <span class="nowrap">200–</span>212. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F77600.77614">10.1145/77600.77614</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:8895683">8895683</a>.</cite></span>
</li>
<li id="cite_note-Chazelle90_2-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-Chazelle90_2_6-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFChazelle1990" class="citation journal cs1">Chazelle, Bernard (1990). <a rel="nofollow" class="external text" href="http://www.cs.princeton.edu/~chazelle/pubs/LBOrthoRangeSearchArithmetic.pdf">"Lower Bounds for Orthogonal Range Searching: II. The Arithmetic Model"</a> <span class="cs1-format">(PDF)</span>. <i>Journal of the ACM</i>. <b>37</b>: <span class="nowrap">439–</span>463. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1145%2F79147.79149">10.1145/79147.79149</a>. <a href="S2CID_(identifier)" class="mw-redirect" title="S2CID (identifier)">S2CID</a> <a rel="nofollow" class="external text" href="https://api.semanticscholar.org/CorpusID:15935619">15935619</a>.</cite></span>
</li>
<li id="cite_note-DutchBook3E-7"><span class="mw-cite-backlink">^ <a href="#cite_ref-DutchBook3E_7-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-DutchBook3E_7-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><cite id="CITEREFde_BergCheongvan_KreveldOvermars2008" class="citation book cs1">de Berg, Mark; Cheong, Otfried; van Kreveld, Marc; Overmars, Mark (2008). <i>Computational Geometry</i>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-540-77974-2">10.1007/978-3-540-77974-2</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a> <bdi>978-3-540-77973-5</bdi>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<ul><li><a rel="nofollow" class="external text" href="http://www.cgal.org/Manual/latest/doc_html/cgal_manual/SearchStructures/Chapter_main.html">Range and Segment Trees</a> in <a href="CGAL" title="CGAL">CGAL</a>, the Computational Geometry Algorithms Library.</li>
<li><a rel="nofollow" class="external text" href="http://www.cs.uu.nl/docs/vakken/ga/2021/slides/slides5b.pdf">Lecture 8: Range Trees</a>, Marc van Kreveld. Archived <a rel="nofollow" class="external text" href="https://archive.today/20230906153801/http://www.cs.uu.nl/docs/vakken/ga/2021/slides/slides5b.pdf">here</a>.</li>
<li><a rel="nofollow" class="external text" href="https://github.com/syhlalala/PAM/tree/master/range_query">Range Trees</a> using <a href="PAM_library" title="PAM library">PAM</a>, the parallel augmented map library.</li>
<li><a rel="nofollow" class="external text" href="https://zhoujoseph.github.io/Orthogonal-range-tree-visualization/">2D Range Tree Visualization</a>, Zhou Kaixuan.</li></ul>
<div class="navbox-styles"><style data-mw-deduplicate="TemplateStyles:r1129693374">
/* start https://en.wikipedia.org/ */
.mw-parser-output .hlist dl,.mw-parser-output .hlist ol,.mw-parser-output .hlist ul{margin:0;padding:0}.mw-parser-output .hlist dd,.mw-parser-output .hlist dt,.mw-parser-output .hlist li{margin:0;display:inline}.mw-parser-output .hlist.inline,.mw-parser-output .hlist.inline dl,.mw-parser-output .hlist.inline ol,.mw-parser-output .hlist.inline ul,.mw-parser-output .hlist dl dl,.mw-parser-output .hlist dl ol,.mw-parser-output .hlist dl ul,.mw-parser-output .hlist ol dl,.mw-parser-output .hlist ol ol,.mw-parser-output .hlist ol ul,.mw-parser-output .hlist ul dl,.mw-parser-output .hlist ul ol,.mw-parser-output .hlist ul ul{display:inline}.mw-parser-output .hlist .mw-empty-li{display:none}.mw-parser-output .hlist dt::after{content:": "}.mw-parser-output .hlist dd::after,.mw-parser-output .hlist li::after{content:" · ";font-weight:bold}.mw-parser-output .hlist dd:last-child::after,.mw-parser-output .hlist dt:last-child::after,.mw-parser-output .hlist li:last-child::after{content:none}.mw-parser-output .hlist dd dd:first-child::before,.mw-parser-output .hlist dd dt:first-child::before,.mw-parser-output .hlist dd li:first-child::before,.mw-parser-output .hlist dt dd:first-child::before,.mw-parser-output .hlist dt dt:first-child::before,.mw-parser-output .hlist dt li:first-child::before,.mw-parser-output .hlist li dd:first-child::before,.mw-parser-output .hlist li dt:first-child::before,.mw-parser-output .hlist li li:first-child::before{content:" (";font-weight:normal}.mw-parser-output .hlist dd dd:last-child::after,.mw-parser-output .hlist dd dt:last-child::after,.mw-parser-output .hlist dd li:last-child::after,.mw-parser-output .hlist dt dd:last-child::after,.mw-parser-output .hlist dt dt:last-child::after,.mw-parser-output .hlist dt li:last-child::after,.mw-parser-output .hlist li dd:last-child::after,.mw-parser-output .hlist li dt:last-child::after,.mw-parser-output .hlist li li:last-child::after{content:")";font-weight:normal}.mw-parser-output .hlist ol{counter-reset:listitem}.mw-parser-output .hlist ol>li{counter-increment:listitem}.mw-parser-output .hlist ol>li::before{content:" "counter(listitem)"\a0 "}.mw-parser-output .hlist dd ol>li:first-child::before,.mw-parser-output .hlist dt ol>li:first-child::before,.mw-parser-output .hlist li ol>li:first-child::before{content:" ("counter(listitem)"\a0 "}
/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1236075235">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbox{box-sizing:border-box;border:1px solid #a2a9b1;width:100%;clear:both;font-size:88%;text-align:center;padding:1px;margin:1em auto 0}.mw-parser-output .navbox .navbox{margin-top:0}.mw-parser-output .navbox+.navbox,.mw-parser-output .navbox+.navbox-styles+.navbox{margin-top:-1px}.mw-parser-output .navbox-inner,.mw-parser-output .navbox-subgroup{width:100%}.mw-parser-output .navbox-group,.mw-parser-output .navbox-title,.mw-parser-output .navbox-abovebelow{padding:0.25em 1em;line-height:1.5em;text-align:center}.mw-parser-output .navbox-group{white-space:nowrap;text-align:right}.mw-parser-output .navbox,.mw-parser-output .navbox-subgroup{background-color:#fdfdfd}.mw-parser-output .navbox-list{line-height:1.5em;border-color:#fdfdfd}.mw-parser-output .navbox-list-with-group{text-align:left;border-left-width:2px;border-left-style:solid}.mw-parser-output tr+tr>.navbox-abovebelow,.mw-parser-output tr+tr>.navbox-group,.mw-parser-output tr+tr>.navbox-image,.mw-parser-output tr+tr>.navbox-list{border-top:2px solid #fdfdfd}.mw-parser-output .navbox-title{background-color:#ccf}.mw-parser-output .navbox-abovebelow,.mw-parser-output .navbox-group,.mw-parser-output .navbox-subgroup .navbox-title{background-color:#ddf}.mw-parser-output .navbox-subgroup .navbox-group,.mw-parser-output .navbox-subgroup .navbox-abovebelow{background-color:#e6e6ff}.mw-parser-output .navbox-even{background-color:#f7f7f7}.mw-parser-output .navbox-odd{background-color:transparent}.mw-parser-output .navbox .hlist td dl,.mw-parser-output .navbox .hlist td ol,.mw-parser-output .navbox .hlist td ul,.mw-parser-output .navbox td.hlist dl,.mw-parser-output .navbox td.hlist ol,.mw-parser-output .navbox td.hlist ul{padding:0.125em 0}.mw-parser-output .navbox .navbar{display:block;font-size:100%}.mw-parser-output .navbox-title .navbar{float:left;text-align:left;margin-right:0.5em}body.skin--responsive .mw-parser-output .navbox-image img{max-width:none!important}@media print{body.ns-0 .mw-parser-output .navbox{display:none!important}}
/* end https://en.wikipedia.org/ */
</style></div><div role="navigation" class="navbox" aria-labelledby="Tree_data_structures246" style="padding:3px"><table class="nowraplinks mw-collapsible autocollapse navbox-inner" style="border-spacing:0;background:transparent;color:inherit"><tbody><tr><th scope="col" class="navbox-title" colspan="2"><style data-mw-deduplicate="TemplateStyles:r1239400231">
/* start https://en.wikipedia.org/ */
.mw-parser-output .navbar{display:inline;font-size:88%;font-weight:normal}.mw-parser-output .navbar-collapse{float:left;text-align:left}.mw-parser-output .navbar-boxtext{word-spacing:0}.mw-parser-output .navbar ul{display:inline-block;white-space:nowrap;line-height:inherit}.mw-parser-output .navbar-brackets::before{margin-right:-0.125em;content:"[ "}.mw-parser-output .navbar-brackets::after{margin-left:-0.125em;content:" ]"}.mw-parser-output .navbar li{word-spacing:-0.125em}.mw-parser-output .navbar a>span,.mw-parser-output .navbar a>abbr{text-decoration:inherit}.mw-parser-output .navbar-mini abbr{font-variant:small-caps;border-bottom:none;text-decoration:none;cursor:inherit}.mw-parser-output .navbar-ct-full{font-size:114%;margin:0 7em}.mw-parser-output .navbar-ct-mini{font-size:114%;margin:0 4em}html.skin-theme-clientpref-night .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}@media(prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .navbar li a abbr{color:var(--color-base)!important}}@media print{.mw-parser-output .navbar{display:none!important}}
/* end https://en.wikipedia.org/ */
</style><div id="Tree_data_structures246" style="font-size:114%;margin:0 4em"><a href="Tree_(abstract_data_type)" title="Tree (abstract data type)">Tree data structures</a></div></th></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Search_tree" title="Search tree">Search trees</a><br>(<a href="Set_(abstract_data_type)" title="Set (abstract data type)">dynamic sets</a>,<br><a href="Associative_array" title="Associative array">associative arrays</a>)</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="2%E2%80%933_tree" title="2–3 tree">2–3</a></li>
<li><a href="2%E2%80%933%E2%80%934_tree" title="2–3–4 tree">2–3–4</a></li>
<li><a href="AA_tree" title="AA tree">AA</a></li>
<li><a href="(a%2Cb)-tree" class="mw-redirect" title="(a,b)-tree">(a,b)</a></li>
<li><a href="AVL_tree" title="AVL tree">AVL</a></li>
<li><a href="B-tree" title="B-tree">B</a>
<ul><li><a href="K-D-B-tree" title="K-D-B-tree">K-Dimensional</a></li></ul></li>
<li><a href="B%2B_tree" title="B+ tree">B+</a></li>
<li><a href="B*-tree" class="mw-redirect" title="B*-tree">B*</a></li>
<li><a href="Bx-tree" title="Bx-tree">B<sup>x</sup></a></li>
<li><a href="Binary_search_tree" title="Binary search tree">Binary search</a>
<ul><li><a href="Optimal_binary_search_tree" title="Optimal binary search tree">Optimal</a></li>
<li><a href="Self-balancing_binary_search_tree" title="Self-balancing binary search tree">Self-balancing</a></li></ul></li>
<li><a href="Dancing_tree" title="Dancing tree">Dancing</a></li>
<li><a href="HTree" title="HTree">HTree</a></li>
<li><a href="Interval_tree" title="Interval tree">Interval</a></li>
<li><a href="Order_statistic_tree" title="Order statistic tree">Order statistic</a></li>
<li><a href="Palindrome_tree" title="Palindrome tree">Palindrome</a></li>
<li>(<a href="Left-leaning_red%E2%80%93black_tree" title="Left-leaning red–black tree">Left-leaning</a>) <a href="Red%E2%80%93black_tree" title="Red–black tree">Red–black</a></li>
<li><a href="Scapegoat_tree" title="Scapegoat tree">Scapegoat</a></li>
<li><a href="Splay_tree" title="Splay tree">Splay</a></li>
<li><a href="T-tree" title="T-tree">T</a></li>
<li><a href="Treap" title="Treap">Treap</a></li>
<li><a href="UB-tree" title="UB-tree">UB</a></li>
<li><a href="Weight-balanced_tree" title="Weight-balanced tree">Weight-balanced</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Heap_(data_structure)" title="Heap (data structure)">Heaps</a></th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Binary_heap" title="Binary heap">Binary</a></li>
<li><a href="Binomial_heap" title="Binomial heap">Binomial</a></li>
<li><a href="Brodal_queue" title="Brodal queue">Brodal</a></li>
<li><a href="D-ary_heap" title="D-ary heap"><i>d</i>-ary</a></li>
<li><a href="Fibonacci_heap" title="Fibonacci heap">Fibonacci</a></li>
<li><a href="Leftist_tree" title="Leftist tree">Leftist</a></li>
<li><a href="Pairing_heap" title="Pairing heap">Pairing</a></li>
<li><a href="Skew_binomial_heap" title="Skew binomial heap">Skew binomial</a></li>
<li><a href="Skew_heap" title="Skew heap">Skew</a></li>
<li><a href="Van_Emde_Boas_tree" title="Van Emde Boas tree">van Emde Boas</a></li>
<li><a href="Weak_heap" title="Weak heap">Weak</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Trie" title="Trie">Tries</a></th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ctrie" title="Ctrie">Ctrie</a></li>
<li><a href="C-trie" title="C-trie">C-trie</a> (compressed ADT)</li>
<li><a href="Hash_tree_(persistent_data_structure)" title="Hash tree (persistent data structure)">Hash</a></li>
<li><a href="Radix_tree" title="Radix tree">Radix</a></li>
<li><a href="Suffix_tree" title="Suffix tree">Suffix</a></li>
<li><a href="Ternary_search_tree" title="Ternary search tree">Ternary search</a></li>
<li><a href="X-fast_trie" title="X-fast trie">X-fast</a></li>
<li><a href="Y-fast_trie" title="Y-fast trie">Y-fast</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%"><a href="Spatial_index" class="mw-redirect" title="Spatial index">Spatial</a> data<br>partitioning trees</th><td class="navbox-list-with-group navbox-list navbox-even hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Ball_tree" title="Ball tree">Ball</a></li>
<li><a href="BK-tree" title="BK-tree">BK</a></li>
<li><a href="BSP_tree" class="mw-redirect" title="BSP tree">BSP</a></li>
<li><a href="Cartesian_tree" title="Cartesian tree">Cartesian</a></li>
<li><a href="Hilbert_R-tree" title="Hilbert R-tree">Hilbert R</a></li>
<li><a href="K-d_tree" title="K-d tree"><i>k</i>-d</a> (<a href="Implicit_k-d_tree" title="Implicit k-d tree">implicit <i>k</i>-d</a>)</li>
<li><a href="M-tree" title="M-tree">M</a></li>
<li><a href="Metric_tree" title="Metric tree">Metric</a></li>
<li><a href="MVP_tree" class="mw-redirect" title="MVP tree">MVP</a></li>
<li><a href="Octree" title="Octree">Octree</a></li>
<li><a href="PH-tree" title="PH-tree">PH</a></li>
<li><a href="Priority_R-tree" title="Priority R-tree">Priority R</a></li>
<li><a href="Quadtree" title="Quadtree">Quad</a></li>
<li><a href="R-tree" title="R-tree">R</a></li>
<li><a href="R%2B_tree" title="R+ tree">R+</a></li>
<li><a href="R*_tree" class="mw-redirect" title="R* tree">R*</a></li>
<li><a href="Segment_tree" title="Segment tree">Segment</a></li>
<li><a href="Vantage-point_tree" title="Vantage-point tree">VP</a></li>
<li><a href="X-tree" title="X-tree">X</a></li></ul>
</div></td></tr><tr><th scope="row" class="navbox-group" style="width:1%">Other trees</th><td class="navbox-list-with-group navbox-list navbox-odd hlist" style="width:100%;padding:0"><div style="padding:0 0.25em">
<ul><li><a href="Cover_tree" title="Cover tree">Cover</a></li>
<li><a href="Exponential_tree" title="Exponential tree">Exponential</a></li>
<li><a href="Fenwick_tree" title="Fenwick tree">Fenwick</a></li>
<li><a href="Finger_tree" title="Finger tree">Finger</a></li>
<li><a href="Fractal_tree_index" title="Fractal tree index">Fractal index</a></li>
<li><a href="Fusion_tree" title="Fusion tree">Fusion</a></li>
<li><a href="Hash_calendar" title="Hash calendar">Hash calendar</a></li>
<li><a href="IDistance" title="IDistance">iDistance</a></li>
<li><a href="K-ary_tree" class="mw-redirect" title="K-ary tree">K-ary</a></li>
<li><a href="Left-child_right-sibling_binary_tree" title="Left-child right-sibling binary tree">Left-child right-sibling</a></li>
<li><a href="Link/cut_tree" title="Link/cut tree">Link/cut</a></li>
<li><a href="Log-structured_merge-tree" title="Log-structured merge-tree">Log-structured merge</a></li>
<li><a href="Merkle_tree" title="Merkle tree">Merkle</a></li>
<li><a href="PQ_tree" title="PQ tree">PQ</a></li>
<li><a href="SPQR_tree" title="SPQR tree">SPQR</a></li>
<li><a href="Top_tree" title="Top tree">Top</a></li></ul>
</div></td></tr></tbody></table></div></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-23" href="https://en.wikipedia.org/wiki/?title=Range_tree&oldid=1302084633">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>
</body></html>